package com.iyao_app.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;
import com.iyao_app.R;
import com.iyao_app.entry.SearchData;
import com.iyao_app.util.DistanceUtil;
import com.iyao_app.util.MarkUtil;
import com.iyao_app.util.ResourcesUtils;

import java.util.List;

/**
 * 作者 :  胡家兵
 * 时间 :  2017/11/27.
 */

public class SearchAdapter extends BaseQuickAdapter<SearchData, BaseViewHolder> {


    public SearchAdapter(@Nullable List<SearchData> data) {
        super(R.layout.item_search, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, SearchData item) {
        SimpleDraweeView mSdvHead = helper.getView(R.id.sdv_head);
        TextView mTvLocation = helper.getView(R.id.tv_location);
        TextView mTvLocationDetail = helper.getView(R.id.tv_location_detail);
        TextView mTvDistance = helper.getView(R.id.tv_distance);
        helper.itemView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) ResourcesUtils.getDimension(R.dimen.x96)));
        mTvLocation.setText(item.getName());
        mTvLocationDetail.setText(item.getAddress());
        mTvDistance.setText(DistanceUtil.getDitance(item.getDistance()));
        mSdvHead.setImageResource(MarkUtil.getId(item.getTypecode()));

    }

}
